{
  "cells": [
    {
      "cell_type": "markdown",
      "metadata": {
        "id": "view-in-github",
        "colab_type": "text"
      },
      "source": [
        "<a href=\"https://colab.research.google.com/github/caitlinmac/heart-beat-decoder/blob/model-colab/Enrika_Basic_Model-COLAB.ipynb\" target=\"_parent\"><img src=\"https://colab.research.google.com/assets/colab-badge.svg\" alt=\"Open In Colab\"/></a>"
      ]
    },
    {
      "cell_type": "code",
      "execution_count": 2,
      "id": "445d1aa5-590c-4f33-889e-88bf91fe57c1",
      "metadata": {
        "id": "445d1aa5-590c-4f33-889e-88bf91fe57c1"
      },
      "outputs": [],
      "source": [
        "import numpy as np\n",
        "import pandas as pd\n",
        "import matplotlib.pyplot as plt\n",
        "from sklearn.model_selection import train_test_split, cross_val_score, StratifiedKFold, GridSearchCV, learning_curve\n",
        "from sklearn.preprocessing import MinMaxScaler\n",
        "from imblearn.over_sampling import SMOTE\n",
        "from sklearn.ensemble import RandomForestClassifier\n",
        "from sklearn.metrics import classification_report, confusion_matrix, accuracy_score"
      ]
    },
    {
      "cell_type": "code",
      "source": [
        "import os\n",
        "\n",
        "file_path = '/content/INCART 2-lead Arrhythmia Database.csv'\n",
        "\n",
        "if not os.path.exists(file_path):\n",
        "    print(\"File not found\")\n",
        "else:\n",
        "    data = pd.read_csv(file_path)"
      ],
      "metadata": {
        "id": "Nn0VkY67DaAt"
      },
      "id": "Nn0VkY67DaAt",
      "execution_count": 3,
      "outputs": []
    },
    {
      "cell_type": "code",
      "source": [
        "from google.colab import drive\n",
        "drive.mount('/content/drive')"
      ],
      "metadata": {
        "colab": {
          "base_uri": "https://localhost:8080/"
        },
        "id": "vehja7vnquVo",
        "outputId": "1f8b6683-be57-4f06-fddb-22fffe55d9d7"
      },
      "id": "vehja7vnquVo",
      "execution_count": 1,
      "outputs": [
        {
          "output_type": "stream",
          "name": "stdout",
          "text": [
            "Mounted at /content/drive\n"
          ]
        }
      ]
    },
    {
      "cell_type": "code",
      "execution_count": 10,
      "id": "cdca77b3-8d8b-45ff-910f-a1ed320bdaad",
      "metadata": {
        "id": "cdca77b3-8d8b-45ff-910f-a1ed320bdaad"
      },
      "outputs": [],
      "source": [
        "# data = pd.read_csv('/Users/enrikasoucy/Downloads/archive (13)/INCART 2-lead Arrhythmia Database.csv')"
      ]
    },
    {
      "cell_type": "code",
      "execution_count": 4,
      "id": "6c3a8193-931a-4eec-8350-68d8eaccfeb2",
      "metadata": {
        "id": "6c3a8193-931a-4eec-8350-68d8eaccfeb2"
      },
      "outputs": [],
      "source": [
        "subset_fraction = 1.0\n",
        "data_subset = data.sample(frac=subset_fraction, random_state=42)"
      ]
    },
    {
      "cell_type": "code",
      "execution_count": 5,
      "id": "b9a0fc08-7ca0-4dd3-b27f-172959a8aa02",
      "metadata": {
        "id": "b9a0fc08-7ca0-4dd3-b27f-172959a8aa02",
        "colab": {
          "base_uri": "https://localhost:8080/",
          "height": 273
        },
        "outputId": "1679747d-b411-449a-c106-a6a4e698031f"
      },
      "outputs": [
        {
          "output_type": "execute_result",
          "data": {
            "text/plain": [
              "      record type  0_pre-RR  0_post-RR   0_pPeak   0_tPeak   0_rPeak  \\\n",
              "28908    I12    N       196        193 -0.053282 -0.411673  1.591223   \n",
              "78394    I34    N       267        317 -0.074312 -0.311586  1.144363   \n",
              "41966    I18    N       134        137  0.269407  1.359665 -0.006546   \n",
              "1424     I01    N       170        102 -0.068883 -0.122126  0.685096   \n",
              "76023    I33    N       346        333  0.101155 -0.359626  1.119283   \n",
              "\n",
              "        0_sPeak   0_qPeak  0_qrs_interval  ...   1_qPeak  1_qrs_interval  \\\n",
              "28908 -0.690581 -0.068750              18  ... -0.022131             6.0   \n",
              "78394 -0.612171 -0.119342              18  ... -0.361235             4.0   \n",
              "41966 -0.006546 -0.231990              11  ... -0.080435            16.0   \n",
              "1424  -0.342469 -0.112441              17  ...  0.086706            14.0   \n",
              "76023 -0.563086 -0.120834              27  ... -0.352931             4.0   \n",
              "\n",
              "       1_pq_interval  1_qt_interval  1_st_interval  1_qrs_morph0  \\\n",
              "28908            2.0           15.0            7.0     -0.022131   \n",
              "78394            5.0           25.0           16.0     -0.361235   \n",
              "41966            8.0           32.0            8.0     -0.080435   \n",
              "1424             3.0           23.0            6.0      0.086706   \n",
              "76023            5.0           24.0           15.0     -0.352931   \n",
              "\n",
              "       1_qrs_morph1  1_qrs_morph2  1_qrs_morph3  1_qrs_morph4  \n",
              "28908     -0.116368     -0.241496     -0.379801     -0.507499  \n",
              "78394     -0.361235     -0.568532     -0.754135     -0.881001  \n",
              "41966     -0.061559      0.050498      0.130689     -0.561149  \n",
              "1424       0.113618      0.223352      0.165030     -0.225114  \n",
              "76023     -0.352931     -0.565260     -0.773874     -0.938588  \n",
              "\n",
              "[5 rows x 34 columns]"
            ],
            "text/html": [
              "\n",
              "  <div id=\"df-a6a7afdf-bda9-460c-8661-67c3009a2933\" class=\"colab-df-container\">\n",
              "    <div>\n",
              "<style scoped>\n",
              "    .dataframe tbody tr th:only-of-type {\n",
              "        vertical-align: middle;\n",
              "    }\n",
              "\n",
              "    .dataframe tbody tr th {\n",
              "        vertical-align: top;\n",
              "    }\n",
              "\n",
              "    .dataframe thead th {\n",
              "        text-align: right;\n",
              "    }\n",
              "</style>\n",
              "<table border=\"1\" class=\"dataframe\">\n",
              "  <thead>\n",
              "    <tr style=\"text-align: right;\">\n",
              "      <th></th>\n",
              "      <th>record</th>\n",
              "      <th>type</th>\n",
              "      <th>0_pre-RR</th>\n",
              "      <th>0_post-RR</th>\n",
              "      <th>0_pPeak</th>\n",
              "      <th>0_tPeak</th>\n",
              "      <th>0_rPeak</th>\n",
              "      <th>0_sPeak</th>\n",
              "      <th>0_qPeak</th>\n",
              "      <th>0_qrs_interval</th>\n",
              "      <th>...</th>\n",
              "      <th>1_qPeak</th>\n",
              "      <th>1_qrs_interval</th>\n",
              "      <th>1_pq_interval</th>\n",
              "      <th>1_qt_interval</th>\n",
              "      <th>1_st_interval</th>\n",
              "      <th>1_qrs_morph0</th>\n",
              "      <th>1_qrs_morph1</th>\n",
              "      <th>1_qrs_morph2</th>\n",
              "      <th>1_qrs_morph3</th>\n",
              "      <th>1_qrs_morph4</th>\n",
              "    </tr>\n",
              "  </thead>\n",
              "  <tbody>\n",
              "    <tr>\n",
              "      <th>28908</th>\n",
              "      <td>I12</td>\n",
              "      <td>N</td>\n",
              "      <td>196</td>\n",
              "      <td>193</td>\n",
              "      <td>-0.053282</td>\n",
              "      <td>-0.411673</td>\n",
              "      <td>1.591223</td>\n",
              "      <td>-0.690581</td>\n",
              "      <td>-0.068750</td>\n",
              "      <td>18</td>\n",
              "      <td>...</td>\n",
              "      <td>-0.022131</td>\n",
              "      <td>6.0</td>\n",
              "      <td>2.0</td>\n",
              "      <td>15.0</td>\n",
              "      <td>7.0</td>\n",
              "      <td>-0.022131</td>\n",
              "      <td>-0.116368</td>\n",
              "      <td>-0.241496</td>\n",
              "      <td>-0.379801</td>\n",
              "      <td>-0.507499</td>\n",
              "    </tr>\n",
              "    <tr>\n",
              "      <th>78394</th>\n",
              "      <td>I34</td>\n",
              "      <td>N</td>\n",
              "      <td>267</td>\n",
              "      <td>317</td>\n",
              "      <td>-0.074312</td>\n",
              "      <td>-0.311586</td>\n",
              "      <td>1.144363</td>\n",
              "      <td>-0.612171</td>\n",
              "      <td>-0.119342</td>\n",
              "      <td>18</td>\n",
              "      <td>...</td>\n",
              "      <td>-0.361235</td>\n",
              "      <td>4.0</td>\n",
              "      <td>5.0</td>\n",
              "      <td>25.0</td>\n",
              "      <td>16.0</td>\n",
              "      <td>-0.361235</td>\n",
              "      <td>-0.361235</td>\n",
              "      <td>-0.568532</td>\n",
              "      <td>-0.754135</td>\n",
              "      <td>-0.881001</td>\n",
              "    </tr>\n",
              "    <tr>\n",
              "      <th>41966</th>\n",
              "      <td>I18</td>\n",
              "      <td>N</td>\n",
              "      <td>134</td>\n",
              "      <td>137</td>\n",
              "      <td>0.269407</td>\n",
              "      <td>1.359665</td>\n",
              "      <td>-0.006546</td>\n",
              "      <td>-0.006546</td>\n",
              "      <td>-0.231990</td>\n",
              "      <td>11</td>\n",
              "      <td>...</td>\n",
              "      <td>-0.080435</td>\n",
              "      <td>16.0</td>\n",
              "      <td>8.0</td>\n",
              "      <td>32.0</td>\n",
              "      <td>8.0</td>\n",
              "      <td>-0.080435</td>\n",
              "      <td>-0.061559</td>\n",
              "      <td>0.050498</td>\n",
              "      <td>0.130689</td>\n",
              "      <td>-0.561149</td>\n",
              "    </tr>\n",
              "    <tr>\n",
              "      <th>1424</th>\n",
              "      <td>I01</td>\n",
              "      <td>N</td>\n",
              "      <td>170</td>\n",
              "      <td>102</td>\n",
              "      <td>-0.068883</td>\n",
              "      <td>-0.122126</td>\n",
              "      <td>0.685096</td>\n",
              "      <td>-0.342469</td>\n",
              "      <td>-0.112441</td>\n",
              "      <td>17</td>\n",
              "      <td>...</td>\n",
              "      <td>0.086706</td>\n",
              "      <td>14.0</td>\n",
              "      <td>3.0</td>\n",
              "      <td>23.0</td>\n",
              "      <td>6.0</td>\n",
              "      <td>0.086706</td>\n",
              "      <td>0.113618</td>\n",
              "      <td>0.223352</td>\n",
              "      <td>0.165030</td>\n",
              "      <td>-0.225114</td>\n",
              "    </tr>\n",
              "    <tr>\n",
              "      <th>76023</th>\n",
              "      <td>I33</td>\n",
              "      <td>N</td>\n",
              "      <td>346</td>\n",
              "      <td>333</td>\n",
              "      <td>0.101155</td>\n",
              "      <td>-0.359626</td>\n",
              "      <td>1.119283</td>\n",
              "      <td>-0.563086</td>\n",
              "      <td>-0.120834</td>\n",
              "      <td>27</td>\n",
              "      <td>...</td>\n",
              "      <td>-0.352931</td>\n",
              "      <td>4.0</td>\n",
              "      <td>5.0</td>\n",
              "      <td>24.0</td>\n",
              "      <td>15.0</td>\n",
              "      <td>-0.352931</td>\n",
              "      <td>-0.352931</td>\n",
              "      <td>-0.565260</td>\n",
              "      <td>-0.773874</td>\n",
              "      <td>-0.938588</td>\n",
              "    </tr>\n",
              "  </tbody>\n",
              "</table>\n",
              "<p>5 rows × 34 columns</p>\n",
              "</div>\n",
              "    <div class=\"colab-df-buttons\">\n",
              "\n",
              "  <div class=\"colab-df-container\">\n",
              "    <button class=\"colab-df-convert\" onclick=\"convertToInteractive('df-a6a7afdf-bda9-460c-8661-67c3009a2933')\"\n",
              "            title=\"Convert this dataframe to an interactive table.\"\n",
              "            style=\"display:none;\">\n",
              "\n",
              "  <svg xmlns=\"http://www.w3.org/2000/svg\" height=\"24px\" viewBox=\"0 -960 960 960\">\n",
              "    <path d=\"M120-120v-720h720v720H120Zm60-500h600v-160H180v160Zm220 220h160v-160H400v160Zm0 220h160v-160H400v160ZM180-400h160v-160H180v160Zm440 0h160v-160H620v160ZM180-180h160v-160H180v160Zm440 0h160v-160H620v160Z\"/>\n",
              "  </svg>\n",
              "    </button>\n",
              "\n",
              "  <style>\n",
              "    .colab-df-container {\n",
              "      display:flex;\n",
              "      gap: 12px;\n",
              "    }\n",
              "\n",
              "    .colab-df-convert {\n",
              "      background-color: #E8F0FE;\n",
              "      border: none;\n",
              "      border-radius: 50%;\n",
              "      cursor: pointer;\n",
              "      display: none;\n",
              "      fill: #1967D2;\n",
              "      height: 32px;\n",
              "      padding: 0 0 0 0;\n",
              "      width: 32px;\n",
              "    }\n",
              "\n",
              "    .colab-df-convert:hover {\n",
              "      background-color: #E2EBFA;\n",
              "      box-shadow: 0px 1px 2px rgba(60, 64, 67, 0.3), 0px 1px 3px 1px rgba(60, 64, 67, 0.15);\n",
              "      fill: #174EA6;\n",
              "    }\n",
              "\n",
              "    .colab-df-buttons div {\n",
              "      margin-bottom: 4px;\n",
              "    }\n",
              "\n",
              "    [theme=dark] .colab-df-convert {\n",
              "      background-color: #3B4455;\n",
              "      fill: #D2E3FC;\n",
              "    }\n",
              "\n",
              "    [theme=dark] .colab-df-convert:hover {\n",
              "      background-color: #434B5C;\n",
              "      box-shadow: 0px 1px 3px 1px rgba(0, 0, 0, 0.15);\n",
              "      filter: drop-shadow(0px 1px 2px rgba(0, 0, 0, 0.3));\n",
              "      fill: #FFFFFF;\n",
              "    }\n",
              "  </style>\n",
              "\n",
              "    <script>\n",
              "      const buttonEl =\n",
              "        document.querySelector('#df-a6a7afdf-bda9-460c-8661-67c3009a2933 button.colab-df-convert');\n",
              "      buttonEl.style.display =\n",
              "        google.colab.kernel.accessAllowed ? 'block' : 'none';\n",
              "\n",
              "      async function convertToInteractive(key) {\n",
              "        const element = document.querySelector('#df-a6a7afdf-bda9-460c-8661-67c3009a2933');\n",
              "        const dataTable =\n",
              "          await google.colab.kernel.invokeFunction('convertToInteractive',\n",
              "                                                    [key], {});\n",
              "        if (!dataTable) return;\n",
              "\n",
              "        const docLinkHtml = 'Like what you see? Visit the ' +\n",
              "          '<a target=\"_blank\" href=https://colab.research.google.com/notebooks/data_table.ipynb>data table notebook</a>'\n",
              "          + ' to learn more about interactive tables.';\n",
              "        element.innerHTML = '';\n",
              "        dataTable['output_type'] = 'display_data';\n",
              "        await google.colab.output.renderOutput(dataTable, element);\n",
              "        const docLink = document.createElement('div');\n",
              "        docLink.innerHTML = docLinkHtml;\n",
              "        element.appendChild(docLink);\n",
              "      }\n",
              "    </script>\n",
              "  </div>\n",
              "\n",
              "\n",
              "<div id=\"df-49443336-a5f6-4f02-a8fd-e8393dc0a16b\">\n",
              "  <button class=\"colab-df-quickchart\" onclick=\"quickchart('df-49443336-a5f6-4f02-a8fd-e8393dc0a16b')\"\n",
              "            title=\"Suggest charts\"\n",
              "            style=\"display:none;\">\n",
              "\n",
              "<svg xmlns=\"http://www.w3.org/2000/svg\" height=\"24px\"viewBox=\"0 0 24 24\"\n",
              "     width=\"24px\">\n",
              "    <g>\n",
              "        <path d=\"M19 3H5c-1.1 0-2 .9-2 2v14c0 1.1.9 2 2 2h14c1.1 0 2-.9 2-2V5c0-1.1-.9-2-2-2zM9 17H7v-7h2v7zm4 0h-2V7h2v10zm4 0h-2v-4h2v4z\"/>\n",
              "    </g>\n",
              "</svg>\n",
              "  </button>\n",
              "\n",
              "<style>\n",
              "  .colab-df-quickchart {\n",
              "      --bg-color: #E8F0FE;\n",
              "      --fill-color: #1967D2;\n",
              "      --hover-bg-color: #E2EBFA;\n",
              "      --hover-fill-color: #174EA6;\n",
              "      --disabled-fill-color: #AAA;\n",
              "      --disabled-bg-color: #DDD;\n",
              "  }\n",
              "\n",
              "  [theme=dark] .colab-df-quickchart {\n",
              "      --bg-color: #3B4455;\n",
              "      --fill-color: #D2E3FC;\n",
              "      --hover-bg-color: #434B5C;\n",
              "      --hover-fill-color: #FFFFFF;\n",
              "      --disabled-bg-color: #3B4455;\n",
              "      --disabled-fill-color: #666;\n",
              "  }\n",
              "\n",
              "  .colab-df-quickchart {\n",
              "    background-color: var(--bg-color);\n",
              "    border: none;\n",
              "    border-radius: 50%;\n",
              "    cursor: pointer;\n",
              "    display: none;\n",
              "    fill: var(--fill-color);\n",
              "    height: 32px;\n",
              "    padding: 0;\n",
              "    width: 32px;\n",
              "  }\n",
              "\n",
              "  .colab-df-quickchart:hover {\n",
              "    background-color: var(--hover-bg-color);\n",
              "    box-shadow: 0 1px 2px rgba(60, 64, 67, 0.3), 0 1px 3px 1px rgba(60, 64, 67, 0.15);\n",
              "    fill: var(--button-hover-fill-color);\n",
              "  }\n",
              "\n",
              "  .colab-df-quickchart-complete:disabled,\n",
              "  .colab-df-quickchart-complete:disabled:hover {\n",
              "    background-color: var(--disabled-bg-color);\n",
              "    fill: var(--disabled-fill-color);\n",
              "    box-shadow: none;\n",
              "  }\n",
              "\n",
              "  .colab-df-spinner {\n",
              "    border: 2px solid var(--fill-color);\n",
              "    border-color: transparent;\n",
              "    border-bottom-color: var(--fill-color);\n",
              "    animation:\n",
              "      spin 1s steps(1) infinite;\n",
              "  }\n",
              "\n",
              "  @keyframes spin {\n",
              "    0% {\n",
              "      border-color: transparent;\n",
              "      border-bottom-color: var(--fill-color);\n",
              "      border-left-color: var(--fill-color);\n",
              "    }\n",
              "    20% {\n",
              "      border-color: transparent;\n",
              "      border-left-color: var(--fill-color);\n",
              "      border-top-color: var(--fill-color);\n",
              "    }\n",
              "    30% {\n",
              "      border-color: transparent;\n",
              "      border-left-color: var(--fill-color);\n",
              "      border-top-color: var(--fill-color);\n",
              "      border-right-color: var(--fill-color);\n",
              "    }\n",
              "    40% {\n",
              "      border-color: transparent;\n",
              "      border-right-color: var(--fill-color);\n",
              "      border-top-color: var(--fill-color);\n",
              "    }\n",
              "    60% {\n",
              "      border-color: transparent;\n",
              "      border-right-color: var(--fill-color);\n",
              "    }\n",
              "    80% {\n",
              "      border-color: transparent;\n",
              "      border-right-color: var(--fill-color);\n",
              "      border-bottom-color: var(--fill-color);\n",
              "    }\n",
              "    90% {\n",
              "      border-color: transparent;\n",
              "      border-bottom-color: var(--fill-color);\n",
              "    }\n",
              "  }\n",
              "</style>\n",
              "\n",
              "  <script>\n",
              "    async function quickchart(key) {\n",
              "      const quickchartButtonEl =\n",
              "        document.querySelector('#' + key + ' button');\n",
              "      quickchartButtonEl.disabled = true;  // To prevent multiple clicks.\n",
              "      quickchartButtonEl.classList.add('colab-df-spinner');\n",
              "      try {\n",
              "        const charts = await google.colab.kernel.invokeFunction(\n",
              "            'suggestCharts', [key], {});\n",
              "      } catch (error) {\n",
              "        console.error('Error during call to suggestCharts:', error);\n",
              "      }\n",
              "      quickchartButtonEl.classList.remove('colab-df-spinner');\n",
              "      quickchartButtonEl.classList.add('colab-df-quickchart-complete');\n",
              "    }\n",
              "    (() => {\n",
              "      let quickchartButtonEl =\n",
              "        document.querySelector('#df-49443336-a5f6-4f02-a8fd-e8393dc0a16b button');\n",
              "      quickchartButtonEl.style.display =\n",
              "        google.colab.kernel.accessAllowed ? 'block' : 'none';\n",
              "    })();\n",
              "  </script>\n",
              "</div>\n",
              "\n",
              "    </div>\n",
              "  </div>\n"
            ],
            "application/vnd.google.colaboratory.intrinsic+json": {
              "type": "dataframe",
              "variable_name": "data_subset"
            }
          },
          "metadata": {},
          "execution_count": 5
        }
      ],
      "source": [
        "data_subset.head()"
      ]
    },
    {
      "cell_type": "code",
      "execution_count": 6,
      "id": "6b5e55c7-454a-4f5f-b1a1-7e9e081c81b8",
      "metadata": {
        "colab": {
          "base_uri": "https://localhost:8080/"
        },
        "id": "6b5e55c7-454a-4f5f-b1a1-7e9e081c81b8",
        "outputId": "0f6f1b12-0450-4fe5-878e-a60af3070fe9"
      },
      "outputs": [
        {
          "output_type": "execute_result",
          "data": {
            "text/plain": [
              "(82366, 34)"
            ]
          },
          "metadata": {},
          "execution_count": 6
        }
      ],
      "source": [
        "data_subset.shape"
      ]
    },
    {
      "cell_type": "code",
      "execution_count": 7,
      "id": "08212d74-dcae-40dc-abc8-ca117167942b",
      "metadata": {
        "id": "08212d74-dcae-40dc-abc8-ca117167942b"
      },
      "outputs": [],
      "source": [
        "type_mapping = {\n",
        "    'N': 'Normal',\n",
        "    'SVEB': 'Abnormal',\n",
        "    'VEB': 'Abnormal',\n",
        "    'F': 'Abnormal',\n",
        "    'Q': 'Abnormal'\n",
        "}\n",
        "data_subset['type'] = data_subset['type'].map(type_mapping)"
      ]
    },
    {
      "cell_type": "code",
      "execution_count": 8,
      "id": "57e77597-0ff6-4dda-9222-fa5ea10d44e2",
      "metadata": {
        "id": "57e77597-0ff6-4dda-9222-fa5ea10d44e2"
      },
      "outputs": [],
      "source": [
        "type_counts = data_subset['type'].value_counts()"
      ]
    },
    {
      "cell_type": "code",
      "execution_count": 9,
      "id": "5319e85b-84d6-4003-9e37-381a44bb876e",
      "metadata": {
        "id": "5319e85b-84d6-4003-9e37-381a44bb876e",
        "colab": {
          "base_uri": "https://localhost:8080/"
        },
        "outputId": "1cabde5f-5dd9-4270-e160-a78e804cf225"
      },
      "outputs": [
        {
          "output_type": "stream",
          "name": "stdout",
          "text": [
            "Counts of Each Type:\n",
            "Normal: 73102\n",
            "Abnormal: 9264\n"
          ]
        }
      ],
      "source": [
        "binary_type_names = {\n",
        "    'Normal': 'Normal',\n",
        "    'Abnormal': 'Abnormal'\n",
        "}\n",
        "\n",
        "print(\"Counts of Each Type:\")\n",
        "for type_code, count in type_counts.items():\n",
        "    print(f\"{binary_type_names[type_code]}: {count}\")"
      ]
    },
    {
      "cell_type": "code",
      "execution_count": 10,
      "id": "b00e555e-da0f-4234-9581-c9d64965b841",
      "metadata": {
        "id": "b00e555e-da0f-4234-9581-c9d64965b841",
        "colab": {
          "base_uri": "https://localhost:8080/",
          "height": 607
        },
        "outputId": "4443b730-2883-4301-b5ac-84989bc3fbf6"
      },
      "outputs": [
        {
          "output_type": "display_data",
          "data": {
            "text/plain": [
              "<Figure size 1000x600 with 1 Axes>"
            ],
            "image/png": "iVBORw0KGgoAAAANSUhEUgAAA2QAAAJOCAYAAADYqMQsAAAAOXRFWHRTb2Z0d2FyZQBNYXRwbG90bGliIHZlcnNpb24zLjcuMSwgaHR0cHM6Ly9tYXRwbG90bGliLm9yZy/bCgiHAAAACXBIWXMAAA9hAAAPYQGoP6dpAABWu0lEQVR4nO3deViU9f7/8deALIIOuIIkiuWK+4q0aBpJhqWmFS1K5pIeNIUypczt1NHslMtR83gq9VSeY1ZWirmEqZXkglouYeZxqRRcYRQTkJnfH/24v01YgaEfg+fjurgu5/N5zz3ve/RifM1935/b5nK5XAIAAAAAXHUephsAAAAAgPKKQAYAAAAAhhDIAAAAAMAQAhkAAAAAGEIgAwAAAABDCGQAAAAAYAiBDAAAAAAMIZABAAAAgCEEMgAAAAAwhEAGAEAJZGZmqm/fvqpWrZpsNptmzJhhuiU3EydOlM1m08mTJ023AgAoBgIZAMDNgQMH9Nhjj+n666+Xr6+v7Ha7brrpJs2cOVM//vij6fYkSXPnztXChQuNvHZCQoJWr16tpKQkvfHGG7rjjjt+tdZms/3qz9ChQ69i179v/fr1v9nvz38AAKWngukGAADXjuTkZN17773y8fFR//791axZM+Xl5emzzz7T6NGjtWfPHs2fP990m5o7d66qV6+uRx555Kq/9rp169SzZ089+eSTxaq//fbb1b9//yLjDRs2LO3W/pAmTZrojTfecBtLSkpSpUqV9MwzzxjqCgDKPgIZAECSdPDgQcXGxqpu3bpat26datWqZc3Fx8fr22+/VXJyssEOrw3Hjx9XYGBgsesbNmyohx9++Mo1VEqCgoKK9Dl16lRVr179T9E/APxZccoiAECSNG3aNJ07d06vvfaaWxgrVL9+fY0cOdJ6fPHiRf31r3/VDTfcIB8fH4WFhenpp59Wbm6u2/NsNpsmTpxYZHthYWFuR7gWLlwom82mzz//XImJiapRo4b8/f3Vu3dvnThxwu15e/bs0YYNG6xT6G699VZJUn5+viZNmqQGDRrI19dX1apV080336y1a9f+7v7/73//07333quqVavKz89PHTt2dAughf25XC7NmTOnVE/f+/TTT3XvvfeqTp068vHxUWhoqBISEi55imh6erruu+8+1ahRQxUrVlSjRo0ueQQrKytLjzzyiAIDAxUQEKABAwbo/Pnzl92jy+VSWFiYevbsWWTuwoULCggI0GOPPSbp/05/XLJkiZ5++mkFBwfL399fd999t7777rsiz9+8ebPuuOMOBQQEyM/PT507d9bnn39+2b0CwJ8JR8gAAJKk5cuX6/rrr9eNN95YrPpBgwZp0aJF6tu3r5544glt3rxZU6ZM0ddff61ly5Zddh8jRoxQlSpVNGHCBB06dEgzZszQ8OHDtWTJEknSjBkzNGLECLdT6YKCgiT9tKDFlClTNGjQIHXo0EEOh0Pbtm3T9u3bdfvtt//qa2ZmZurGG2/U+fPn9fjjj6tatWpatGiR7r77br3zzjvq3bu3OnXqpDfeeEP9+vX71dMQL+XChQuXXGDDbrfL29tbkrR06VKdP39ew4YNU7Vq1bRlyxb94x//0Pfff6+lS5daz/nqq690yy23yMvLS0OGDFFYWJgOHDig5cuX6/nnn3fb/n333ad69eppypQp2r59u1599VXVrFlTL7zwQrH6/iWbzaaHH35Y06ZN0+nTp1W1alVrbvny5XI4HEWOpD3//POy2WwaM2aMjh8/rhkzZigqKko7d+5UxYoVJf10Cmj37t3Vtm1bTZgwQR4eHlqwYIG6du2qTz/9VB06dLisfgHgT8MFACj3srOzXZJcPXv2LFb9zp07XZJcgwYNcht/8sknXZJc69ats8YkuSZMmFBkG3Xr1nXFxcVZjxcsWOCS5IqKinI5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n1aderUUePGjfX6669L+r9Q9umnn+rxxx/X4MGDDXcNlA7+pwPgqrDZbFq2bJnuuece7d27Vzk5OYqNjdW0adOUl5enkJAQzZ8/XzfddJOaNm2qffv2EcYAoJyw2WxatWqV+vXrp8cee0xffPGFHnjgAS1cuFC9e/eWJLVs2VJDhw5V69at9eqrryo7O5ubRqNM4AgZgKti27Zt6tWrl8aPH68hQ4YoIyNDDRo0UE5Ojp544glNmTJFFSpU0HfffafRo0dr8uTJatiwoem2AQBXwYkTJzRo0CB17txZiYmJOnHihNq2batmzZppz549atmypT788ENJ0p49e1StWjUFBwcb7hooHXz9DOCKczqd2rdvnx555BENGTJE3333nTp27Ki4uDi99tpreumll6wjZaGhoXrrrbcIYwBQjtSoUUN33nmnbrvtNp04cUJdunRRTEyMli1bpn79+mnFihXq2rWrJKlp06aEMZQpFUw3AKDsKrwmwMPDQ126dFGjRo2Ul5engQMH6rbbbtPMmTN18uRJhYSEaNy4cfrxxx/117/+VZ6enqZbBwBcZY899pgkaf78+apdu7YmTpwoHx8f1a9fXx07dlR+fr4OHz6sunXrGu4UKF0EMgClrjCInT9/Xv7+/nK5XAoJCVFISIiOHj2qkydP6sknn5Snp6d8fHx055136pZbblH79u1Ntw4AuMIKPyO+/PJLHThwQA0aNFCzZs2sVXjT09N18OBBBQUFSZK+/vpr3XrrrRo3bpz8/PxMtg5cEZyyCKDU2Ww2JScn695771Xv3r3173//Ww6HQ5J09uxZffnll/rmm2+UmZmpv//97/riiy/Us2dPNW7c2HDnAIArzWaz6YMPPlBkZKSefvpptWzZUpMmTdKBAwckST169JDT6VTXrl314IMPau7cuerfvz9hDGUWgQxAqdu8ebNiY2PVtGlTnT59WvPmzVNSUpJOnTqlRo0a6fnnn9fjjz+uW265RfPmzdOiRYtkt9tNtw0AuMKcTqdycnL0r3/9SzNnztS2bds0b948zZ8/X7Nnz9bhw4d18803a/LkybLb7XI6ndq0aRNf2KFMY5VFAKXi5zd9fu+997Rz505NnjxZkjRt2jS9//77at68uaZOnaoqVaooNTVV2dnZatq0qUJDQ022DgC4wgo/I7Kzs1WxYkWNGzdO8fHx1vVgCxcu1DPPPKN7771Xo0eP1nXXXSdJys3NlY+Pj8nWgSuOa8gA/GGFH7Rbt27V0aNHtW3bNlWuXNmaf+KJJ2Sz2fTee+9p3LhxmjhxoiIjIw12DAC4mgo/A1544QVlZGTI5XKpR48eViB75JFHJEkTJ05UTk6OxowZo/r16xPGUC4QyAD8YTabTe+++67i4uIUGBio06dPq1GjRho5cqT8/Pzk6empJ554Qh4eHnrttdfk7e2tl156STabzTqqBgAou/bu3ashQ4Zo6NCh+vHHH7VkyRLNnj1blStXVuvWrSX9FMpyc3M1a9Ysty/1gLKOUxYBXLbCI2M5OTkaOXKkbr75Zt15551atmyZ/vnPf6pu3br697//bX2wOp1OzZkzR3fddZfCwsLMNg8AuCp27dqlpUuXyuVy6a9//askacmSJXrppZfUpEkTJSQkqFWrVlZ9dna2AgICDHULXH0s6gHgshWeptihQwcdPXpUN910k2rWrKlBgwZp1KhROnbsmPr166ezZ89Kkjw8PDRixAjCGACUcYXf9//vf//Ts88+q7lz5+rEiRPW/P3336/ExETt2bNH//jHP7R161ZrjkWeUN5wyiKAEis8MrZ9+3b973//U0BAgD799FP5+/tLkjw9PfXggw/KZrNp/vz5uvvuu7V8+XJVqlTJcOcAgKuhcGn7b7/9Vj179lR2drZWrVqlTZs26cYbb5QkxcbGysPDQ08//bR8fHzUokUL+fj4cCo7yh2OkAEoscL7jPXp00d2u12TJk1S7dq11bNnT+Xn50uSKlSooAceeED9+/eXl5eXsrKyzDYNALjiCo+MffPNN+rfv79q1KihAQMGaOzYsWrQoIGef/55paamWvX33Xefpk2bptGjR7OAB8otriEDUGyFR8YyMzP15JNPqn379nr88cfldDr1ySef6IknnlDFihW1fv1664P14sWLOn/+PKegAEA58dlnn+nIkSPaunWrXn75ZeuI1/LlyzVnzhzZbDZNmDBBHTt2NNwpcG3gCBmAYrPZbPr88881YMAA7d+/Xx06dJD007VhnT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VlaWFbLsdrv69u2rV155Ra+//rrbPcfOnTunBg0ayNPT00i/wJ8JpywC5ZTT6ZSHx/99J2Oz2XTjjTfqX//6lx555BFFRERoy5Yt6t27txYsWKCLFy+qf//+8vf31+uvvy4PDw+FhYWZ2wEAwFVjs9n04YcfavLkyfL391dYWJjmz5+vRx99VBkZGRo+fLi2bdumqlWrKicnRytWrFBqaqrb5wyAS2OVRaAcKgxjGRkZOnTokDp27GjN5efna8eOHYqNjVVoaKg2bNig8ePHa9myZfr222/VqlUrHThwQKtXr1br1q0N7gUA4EorXHF3x44duvHGG/XUU0/p7NmzWr9+vfLy8pSWliYfHx+98cYbSk5O1pEjRxQSEqLx48erRYsWptsH/hQIZEA59d1336l169Y6ffq0OnfurMjISEVFRaldu3ay2+3aunWrBg4cKLvdrs8++0wZGRlauXKlqlSpojZt2qhu3bqmdwEAcBVs375dx48f15dffqkxY8aooKBAO3bs0MCBA5WXl6cdO3bI19dX586dk7+/v3Jzc+Xr62u6beBPg0AGlFOHDx9Wr1699OOPP6py5cpq2rSplixZosaNG6t58+bq0aOHbDabkpKSdP3112v16tXWNWQAgPLh5MmT6tSpk9LT0zV27Fj97W9/k/TTkbPt27fr0UcfldPp1NatWwlhwGUikAHl2LfffqunnnpKTqdTSUlJqlWrljZt2qTZs2crPz9fu3fv1g033KDdu3erZ8+eWrZsmXX6CgCg7MvNzVVycrKef/55SVJaWpo153K5tGPHDvXq1UvXXXedUlNTTbUJ/KkRyIBybt++fRo5cqScTqeef/55tW/fXtJPK2ktX75c6enp+uijj/Taa69xzRgAlGGF/yUs/NKt8HrjvLw8paSk6C9/+Yvq16+vtWvXuj3nyy+/lN1u5/YnwGUikAHQ/v37NWLECElSUlKSOnfu7DZ/8eJFVajAoqwAUBb98MMPuu6666zf9WvWrNGHH36oEydOqFevXurSpYuCg4P10UcfaeTIkQoLC9OaNWtMtw2UGaxFCkANGjTQP/7xD9lsNk2ZMkWbNm1ymyeMAUDZ9OGHHyo0NFSfffaZKlSooA8++EB33323vvvuO507d05DhgzRk08+qW3btql79+6aMWOGjh49qg4dOphuHSgzCGQAJP0UymbNmiUvLy898cQT+uKLL0y3BAC4wjp27KjY2Fj16NFDmzZt0t69e/X3v/9dH3zwgZKTk/XOO+/om2++0axZs3Tq1Cnddtttmjx5siTpyJEjhrsHygYCGQBLgwYN9OKLL6p27doKCQkx3Q4A4AopvGKlZs2amjVrlu666y5FRUXp3//+t2rUqGHVRUdH669//aveffddffrpp/Lx8dFdd92lTz75RHXq1DHVPlCmEMgAuGncuLHeeustPmgBoAxyOp2S/m/hDpfLperVq+vvf/+7Bg4cqH379un48eOSpPz8fEk/hbK2bdtqzZo1crlc8vLykr+/v5kdAMogAhmAIry9vU23AAC4Ajw8PJSenq5nnnlGhw8ftgJaUFCQnn76acXFxWnMmDH65JNP5OXlZT3P5XKpatWq3PYEuAJYZREAAKCcyM/P10033aRt27apfv366tmzp9q3b6/77rtPkpSTk6PBgwdr2bJlmjBhgmrUqKH9+/dr7ty52rx5s5o0aWJ4D4Cyh0AGAABQjrz44ouqUKGCmjVrps8//1yzZs3SnXfeqZtvvlmPPfaYsrOzNW7cOM2dO1etW7dWv3791LVrV7Vo0cJ060CZRCADAAAoR9avX6+ePXsqJSVF7dq107FjxzR//nxNnTpVrVu31oABA9SwYUO98847eu+993TgwAH5+vqabhsos7iGDAAAoBy59dZbNWTIEM2YMUMXLlxQrVq19PXXXyssLEwNGjTQ4sWLdfvtt6tSpUravHkzYQy4wrjbKwAAQDkTERGhl19+Wd7e3ho0aJDWr1+vlJQUNW3aVOnp6fr444/VpUsX1a5d23SrQJnHKYsAAADlUOfOnfXZZ58pODhYK1euVMuWLU23BJRLnLIIAABQjhR+Fz9mzBjVr19fc+bMUcuWLcV39IAZBDIAAIBypPBeYm3btpXT6VRaWprbOICri0AGAABQDgUFBWnChAmaPn26tmzZYrodoNwikAEAAJRTXbp0Ufv27RUSEmK6FaDcYlEPAACAcuzChQssbQ8YRCADAAAAAEM4ZREAAAAADCGQAQ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AAAACGcIQMAAAAAAwhkAEAAACAIQQyAAAAADCEQAYAAAAAhhDIAAAAAMAQAhkAAAAAGEIgAwAAAABDCGQAAAAAYMj/Axy6Nh1VcN5PAAAAAElFTkSuQmCC\n"
          },
          "metadata": {}
        }
      ],
      "source": [
        "type_counts.index = type_counts.index.map(binary_type_names)\n",
        "\n",
        "plt.figure(figsize=(10, 6))\n",
        "type_counts.plot(kind='bar', color='skyblue')\n",
        "plt.title('Counts of Each Type')\n",
        "plt.xlabel('Type')\n",
        "plt.ylabel('Count')\n",
        "plt.xticks(rotation=45)\n",
        "plt.grid(axis='y')\n",
        "plt.show()"
      ]
    },
    {
      "cell_type": "code",
      "execution_count": 11,
      "id": "8928a33b-ad70-4f58-8a13-6c73bf2d6121",
      "metadata": {
        "id": "8928a33b-ad70-4f58-8a13-6c73bf2d6121"
      },
      "outputs": [],
      "source": [
        "data_subset = data_subset.drop(columns=['record'])"
      ]
    },
    {
      "cell_type": "code",
      "execution_count": 12,
      "id": "18554c03-4f56-4a53-8bc5-db1a326dfe9d",
      "metadata": {
        "id": "18554c03-4f56-4a53-8bc5-db1a326dfe9d",
        "colab": {
          "base_uri": "https://localhost:8080/",
          "height": 273
        },
        "outputId": "491912aa-23ad-433d-e76d-a2a68f42aa27"
      },
      "outputs": [
        {
          "output_type": "execute_result",
          "data": {
            "text/plain": [
              "         type  0_pre-RR  0_post-RR   0_pPeak   0_tPeak   0_rPeak   0_sPeak  \\\n",
              "28908  Normal       196        193 -0.053282 -0.411673  1.591223 -0.690581   \n",
              "78394  Normal       267        317 -0.074312 -0.311586  1.144363 -0.612171   \n",
              "41966  Normal       134        137  0.269407  1.359665 -0.006546 -0.006546   \n",
              "1424   Normal       170        102 -0.068883 -0.122126  0.685096 -0.342469   \n",
              "76023  Normal       346        333  0.101155 -0.359626  1.119283 -0.563086   \n",
              "\n",
              "        0_qPeak  0_qrs_interval  0_pq_interval  ...   1_qPeak  1_qrs_interval  \\\n",
              "28908 -0.068750              18              4  ... -0.022131             6.0   \n",
              "78394 -0.119342              18              4  ... -0.361235             4.0   \n",
              "41966 -0.231990              11             13  ... -0.080435            16.0   \n",
              "1424  -0.112441              17              5  ...  0.086706            14.0   \n",
              "76023 -0.120834              27             19  ... -0.352931             4.0   \n",
              "\n",
              "       1_pq_interval  1_qt_interval  1_st_interval  1_qrs_morph0  \\\n",
              "28908            2.0           15.0            7.0     -0.022131   \n",
              "78394            5.0           25.0           16.0     -0.361235   \n",
              "41966            8.0           32.0            8.0     -0.080435   \n",
              "1424             3.0           23.0            6.0      0.086706   \n",
              "76023            5.0           24.0           15.0     -0.352931   \n",
              "\n",
              "       1_qrs_morph1  1_qrs_morph2  1_qrs_morph3  1_qrs_morph4  \n",
              "28908     -0.116368     -0.241496     -0.379801     -0.507499  \n",
              "78394     -0.361235     -0.568532     -0.754135     -0.881001  \n",
              "41966     -0.061559      0.050498      0.130689     -0.561149  \n",
              "1424       0.113618      0.223352      0.165030     -0.225114  \n",
              "76023     -0.352931     -0.565260     -0.773874     -0.938588  \n",
              "\n",
              "[5 rows x 33 columns]"
            ],
            "text/html": [
              "\n",
              "  <div id=\"df-8ae87ba8-920b-471d-97ba-245b89e78406\" class=\"colab-df-container\">\n",
              "    <div>\n",
              "<style scoped>\n",
              "    .dataframe tbody tr th:only-of-type {\n",
              "        vertical-align: middle;\n",
              "    }\n",
              "\n",
              "    .dataframe tbody tr th {\n",
              "        vertical-align: top;\n",
              "    }\n",
              "\n",
              "    .dataframe thead th {\n",
              "        text-align: right;\n",
              "    }\n",
              "</style>\n",
              "<table border=\"1\" class=\"dataframe\">\n",
              "  <thead>\n",
              "    <tr style=\"text-align: right;\">\n",
              "      <th></th>\n",
              "      <th>type</th>\n",
              "      <th>0_pre-RR</th>\n",
              "      <th>0_post-RR</th>\n",
              "      <th>0_pPeak</th>\n",
              "      <th>0_tPeak</th>\n",
              "      <th>0_rPeak</th>\n",
              "      <th>0_sPeak</th>\n",
              "      <th>0_qPeak</th>\n",
              "      <th>0_qrs_interval</th>\n",
              "      <th>0_pq_interval</th>\n",
              "      <th>...</th>\n",
              "      <th>1_qPeak</th>\n",
              "      <th>1_qrs_interval</th>\n",
              "      <th>1_pq_interval</th>\n",
              "      <th>1_qt_interval</th>\n",
              "      <th>1_st_interval</th>\n",
              "      <th>1_qrs_morph0</th>\n",
              "      <th>1_qrs_morph1</th>\n",
              "      <th>1_qrs_morph2</th>\n",
              "      <th>1_qrs_morph3</th>\n",
              "      <th>1_qrs_morph4</th>\n",
              "    </tr>\n",
              "  </thead>\n",
              "  <tbody>\n",
              "    <tr>\n",
              "      <th>28908</th>\n",
              "      <td>Normal</td>\n",
              "      <td>196</td>\n",
              "      <td>193</td>\n",
              "      <td>-0.053282</td>\n",
              "      <td>-0.411673</td>\n",
              "      <td>1.591223</td>\n",
              "      <td>-0.690581</td>\n",
              "      <td>-0.068750</td>\n",
              "      <td>18</td>\n",
              "      <td>4</td>\n",
              "      <td>...</td>\n",
              "      <td>-0.022131</td>\n",
              "      <td>6.0</td>\n",
              "      <td>2.0</td>\n",
              "      <td>15.0</td>\n",
              "      <td>7.0</td>\n",
              "      <td>-0.022131</td>\n",
              "      <td>-0.116368</td>\n",
              "      <td>-0.241496</td>\n",
              "      <td>-0.379801</td>\n",
              "      <td>-0.507499</td>\n",
              "    </tr>\n",
              "    <tr>\n",
              "      <th>78394</th>\n",
              "      <td>Normal</td>\n",
              "      <td>267</td>\n",
              "      <td>317</td>\n",
              "      <td>-0.074312</td>\n",
              "      <td>-0.311586</td>\n",
              "      <td>1.144363</td>\n",
              "      <td>-0.612171</td>\n",
              "      <td>-0.119342</td>\n",
              "      <td>18</td>\n",
              "      <td>4</td>\n",
              "      <td>...</td>\n",
              "      <td>-0.361235</td>\n",
              "      <td>4.0</td>\n",
              "      <td>5.0</td>\n",
              "      <td>25.0</td>\n",
              "      <td>16.0</td>\n",
              "      <td>-0.361235</td>\n",
              "      <td>-0.361235</td>\n",
              "      <td>-0.568532</td>\n",
              "      <td>-0.754135</td>\n",
              "      <td>-0.881001</td>\n",
              "    </tr>\n",
              "    <tr>\n",
              "      <th>41966</th>\n",
              "      <td>Normal</td>\n",
              "      <td>134</td>\n",
              "      <td>137</td>\n",
              "      <td>0.269407</td>\n",
              "      <td>1.359665</td>\n",
              "      <td>-0.006546</td>\n",
              "      <td>-0.006546</td>\n",
              "      <td>-0.231990</td>\n",
              "      <td>11</td>\n",
              "      <td>13</td>\n",
              "      <td>...</td>\n",
              "      <td>-0.080435</td>\n",
              "      <td>16.0</td>\n",
              "      <td>8.0</td>\n",
              "      <td>32.0</td>\n",
              "      <td>8.0</td>\n",
              "      <td>-0.080435</td>\n",
              "      <td>-0.061559</td>\n",
              "      <td>0.050498</td>\n",
              "      <td>0.130689</td>\n",
              "      <td>-0.561149</td>\n",
              "    </tr>\n",
              "    <tr>\n",
              "      <th>1424</th>\n",
              "      <td>Normal</td>\n",
              "      <td>170</td>\n",
              "      <td>102</td>\n",
              "      <td>-0.068883</td>\n",
              "      <td>-0.122126</td>\n",
              "      <td>0.685096</td>\n",
              "      <td>-0.342469</td>\n",
              "      <td>-0.112441</td>\n",
              "      <td>17</td>\n",
              "      <td>5</td>\n",
              "      <td>...</td>\n",
              "      <td>0.086706</td>\n",
              "      <td>14.0</td>\n",
              "      <td>3.0</td>\n",
              "      <td>23.0</td>\n",
              "      <td>6.0</td>\n",
              "      <td>0.086706</td>\n",
              "      <td>0.113618</td>\n",
              "      <td>0.223352</td>\n",
              "      <td>0.165030</td>\n",
              "      <td>-0.225114</td>\n",
              "    </tr>\n",
              "    <tr>\n",
              "      <th>76023</th>\n",
              "      <td>Normal</td>\n",
              "      <td>346</td>\n",
              "      <td>333</td>\n",
              "      <td>0.101155</td>\n",
              "      <td>-0.359626</td>\n",
              "      <td>1.119283</td>\n",
              "      <td>-0.563086</td>\n",
              "      <td>-0.120834</td>\n",
              "      <td>27</td>\n",
              "      <td>19</td>\n",
              "      <td>...</td>\n",
              "      <td>-0.352931</td>\n",
              "      <td>4.0</td>\n",
              "      <td>5.0</td>\n",
              "      <td>24.0</td>\n",
              "      <td>15.0</td>\n",
              "      <td>-0.352931</td>\n",
              "      <td>-0.352931</td>\n",
              "      <td>-0.565260</td>\n",
              "      <td>-0.773874</td>\n",
              "      <td>-0.938588</td>\n",
              "    </tr>\n",
              "  </tbody>\n",
              "</table>\n",
              "<p>5 rows × 33 columns</p>\n",
              "</div>\n",
              "    <div class=\"colab-df-buttons\">\n",
              "\n",
              "  <div class=\"colab-df-container\">\n",
              "    <button class=\"colab-df-convert\" onclick=\"convertToInteractive('df-8ae87ba8-920b-471d-97ba-245b89e78406')\"\n",
              "            title=\"Convert this dataframe to an interactive table.\"\n",
              "            style=\"display:none;\">\n",
              "\n",
              "  <svg xmlns=\"http://www.w3.org/2000/svg\" height=\"24px\" viewBox=\"0 -960 960 960\">\n",
              "    <path d=\"M120-120v-720h720v720H120Zm60-500h600v-160H180v160Zm220 220h160v-160H400v160Zm0 220h160v-160H400v160ZM180-400h160v-160H180v160Zm440 0h160v-160H620v160ZM180-180h160v-160H180v160Zm440 0h160v-160H620v160Z\"/>\n",
              "  </svg>\n",
              "    </button>\n",
              "\n",
              "  <style>\n",
              "    .colab-df-container {\n",
              "      display:flex;\n",
              "      gap: 12px;\n",
              "    }\n",
              "\n",
              "    .colab-df-convert {\n",
              "      background-color: #E8F0FE;\n",
              "      border: none;\n",
              "      border-radius: 50%;\n",
              "      cursor: pointer;\n",
              "      display: none;\n",
              "      fill: #1967D2;\n",
              "      height: 32px;\n",
              "      padding: 0 0 0 0;\n",
              "      width: 32px;\n",
              "    }\n",
              "\n",
              "    .colab-df-convert:hover {\n",
              "      background-color: #E2EBFA;\n",
              "      box-shadow: 0px 1px 2px rgba(60, 64, 67, 0.3), 0px 1px 3px 1px rgba(60, 64, 67, 0.15);\n",
              "      fill: #174EA6;\n",
              "    }\n",
              "\n",
              "    .colab-df-buttons div {\n",
              "      margin-bottom: 4px;\n",
              "    }\n",
              "\n",
              "    [theme=dark] .colab-df-convert {\n",
              "      background-color: #3B4455;\n",
              "      fill: #D2E3FC;\n",
              "    }\n",
              "\n",
              "    [theme=dark] .colab-df-convert:hover {\n",
              "      background-color: #434B5C;\n",
              "      box-shadow: 0px 1px 3px 1px rgba(0, 0, 0, 0.15);\n",
              "      filter: drop-shadow(0px 1px 2px rgba(0, 0, 0, 0.3));\n",
              "      fill: #FFFFFF;\n",
              "    }\n",
              "  </style>\n",
              "\n",
              "    <script>\n",
              "      const buttonEl =\n",
              "        document.querySelector('#df-8ae87ba8-920b-471d-97ba-245b89e78406 button.colab-df-convert');\n",
              "      buttonEl.style.display =\n",
              "        google.colab.kernel.accessAllowed ? 'block' : 'none';\n",
              "\n",
              "      async function convertToInteractive(key) {\n",
              "        const element = document.querySelector('#df-8ae87ba8-920b-471d-97ba-245b89e78406');\n",
              "        const dataTable =\n",
              "          await google.colab.kernel.invokeFunction('convertToInteractive',\n",
              "                                                    [key], {});\n",
              "        if (!dataTable) return;\n",
              "\n",
              "        const docLinkHtml = 'Like what you see? Visit the ' +\n",
              "          '<a target=\"_blank\" href=https://colab.research.google.com/notebooks/data_table.ipynb>data table notebook</a>'\n",
              "          + ' to learn more about interactive tables.';\n",
              "        element.innerHTML = '';\n",
              "        dataTable['output_type'] = 'display_data';\n",
              "        await google.colab.output.renderOutput(dataTable, element);\n",
              "        const docLink = document.createElement('div');\n",
              "        docLink.innerHTML = docLinkHtml;\n",
              "        element.appendChild(docLink);\n",
              "      }\n",
              "    </script>\n",
              "  </div>\n",
              "\n",
              "\n",
              "<div id=\"df-a75c1657-c83f-46a7-93f0-5b277d0c2fc8\">\n",
              "  <button class=\"colab-df-quickchart\" onclick=\"quickchart('df-a75c1657-c83f-46a7-93f0-5b277d0c2fc8')\"\n",
              "            title=\"Suggest charts\"\n",
              "            style=\"display:none;\">\n",
              "\n",
              "<svg xmlns=\"http://www.w3.org/2000/svg\" height=\"24px\"viewBox=\"0 0 24 24\"\n",
              "     width=\"24px\">\n",
              "    <g>\n",
              "        <path d=\"M19 3H5c-1.1 0-2 .9-2 2v14c0 1.1.9 2 2 2h14c1.1 0 2-.9 2-2V5c0-1.1-.9-2-2-2zM9 17H7v-7h2v7zm4 0h-2V7h2v10zm4 0h-2v-4h2v4z\"/>\n",
              "    </g>\n",
              "</svg>\n",
              "  </button>\n",
              "\n",
              "<style>\n",
              "  .colab-df-quickchart {\n",
              "      --bg-color: #E8F0FE;\n",
              "      --fill-color: #1967D2;\n",
              "      --hover-bg-color: #E2EBFA;\n",
              "      --hover-fill-color: #174EA6;\n",
              "      --disabled-fill-color: #AAA;\n",
              "      --disabled-bg-color: #DDD;\n",
              "  }\n",
              "\n",
              "  [theme=dark] .colab-df-quickchart {\n",
              "      --bg-color: #3B4455;\n",
              "      --fill-color: #D2E3FC;\n",
              "      --hover-bg-color: #434B5C;\n",
              "      --hover-fill-color: #FFFFFF;\n",
              "      --disabled-bg-color: #3B4455;\n",
              "      --disabled-fill-color: #666;\n",
              "  }\n",
              "\n",
              "  .colab-df-quickchart {\n",
              "    background-color: var(--bg-color);\n",
              "    border: none;\n",
              "    border-radius: 50%;\n",
              "    cursor: pointer;\n",
              "    display: none;\n",
              "    fill: var(--fill-color);\n",
              "    height: 32px;\n",
              "    padding: 0;\n",
              "    width: 32px;\n",
              "  }\n",
              "\n",
              "  .colab-df-quickchart:hover {\n",
              "    background-color: var(--hover-bg-color);\n",
              "    box-shadow: 0 1px 2px rgba(60, 64, 67, 0.3), 0 1px 3px 1px rgba(60, 64, 67, 0.15);\n",
              "    fill: var(--button-hover-fill-color);\n",
              "  }\n",
              "\n",
              "  .colab-df-quickchart-complete:disabled,\n",
              "  .colab-df-quickchart-complete:disabled:hover {\n",
              "    background-color: var(--disabled-bg-color);\n",
              "    fill: var(--disabled-fill-color);\n",
              "    box-shadow: none;\n",
              "  }\n",
              "\n",
              "  .colab-df-spinner {\n",
              "    border: 2px solid var(--fill-color);\n",
              "    border-color: transparent;\n",
              "    border-bottom-color: var(--fill-color);\n",
              "    animation:\n",
              "      spin 1s steps(1) infinite;\n",
              "  }\n",
              "\n",
              "  @keyframes spin {\n",
              "    0% {\n",
              "      border-color: transparent;\n",
              "      border-bottom-color: var(--fill-color);\n",
              "      border-left-color: var(--fill-color);\n",
              "    }\n",
              "    20% {\n",
              "      border-color: transparent;\n",
              "      border-left-color: var(--fill-color);\n",
              "      border-top-color: var(--fill-color);\n",
              "    }\n",
              "    30% {\n",
              "      border-color: transparent;\n",
              "      border-left-color: var(--fill-color);\n",
              "      border-top-color: var(--fill-color);\n",
              "      border-right-color: var(--fill-color);\n",
              "    }\n",
              "    40% {\n",
              "      border-color: transparent;\n",
              "      border-right-color: var(--fill-color);\n",
              "      border-top-color: var(--fill-color);\n",
              "    }\n",
              "    60% {\n",
              "      border-color: transparent;\n",
              "      border-right-color: var(--fill-color);\n",
              "    }\n",
              "    80% {\n",
              "      border-color: transparent;\n",
              "      border-right-color: var(--fill-color);\n",
              "      border-bottom-color: var(--fill-color);\n",
              "    }\n",
              "    90% {\n",
              "      border-color: transparent;\n",
              "      border-bottom-color: var(--fill-color);\n",
              "    }\n",
              "  }\n",
              "</style>\n",
              "\n",
              "  <script>\n",
              "    async function quickchart(key) {\n",
              "      const quickchartButtonEl =\n",
              "        document.querySelector('#' + key + ' button');\n",
              "      quickchartButtonEl.disabled = true;  // To prevent multiple clicks.\n",
              "      quickchartButtonEl.classList.add('colab-df-spinner');\n",
              "      try {\n",
              "        const charts = await google.colab.kernel.invokeFunction(\n",
              "            'suggestCharts', [key], {});\n",
              "      } catch (error) {\n",
              "        console.error('Error during call to suggestCharts:', error);\n",
              "      }\n",
              "      quickchartButtonEl.classList.remove('colab-df-spinner');\n",
              "      quickchartButtonEl.classList.add('colab-df-quickchart-complete');\n",
              "    }\n",
              "    (() => {\n",
              "      let quickchartButtonEl =\n",
              "        document.querySelector('#df-a75c1657-c83f-46a7-93f0-5b277d0c2fc8 button');\n",
              "      quickchartButtonEl.style.display =\n",
              "        google.colab.kernel.accessAllowed ? 'block' : 'none';\n",
              "    })();\n",
              "  </script>\n",
              "</div>\n",
              "\n",
              "    </div>\n",
              "  </div>\n"
            ],
            "application/vnd.google.colaboratory.intrinsic+json": {
              "type": "dataframe",
              "variable_name": "data_subset"
            }
          },
          "metadata": {},
          "execution_count": 12
        }
      ],
      "source": [
        "data_subset.head()"
      ]
    },
    {
      "cell_type": "code",
      "execution_count": 13,
      "id": "72f1fed6-e839-4716-a2c9-2163d55ee1b5",
      "metadata": {
        "id": "72f1fed6-e839-4716-a2c9-2163d55ee1b5"
      },
      "outputs": [],
      "source": [
        "X = data_subset.drop('type', axis=1)\n",
        "y = data_subset['type']"
      ]
    },
    {
      "cell_type": "code",
      "execution_count": 14,
      "id": "76099631-bb3e-411d-a624-3c8e1d3a454c",
      "metadata": {
        "id": "76099631-bb3e-411d-a624-3c8e1d3a454c"
      },
      "outputs": [],
      "source": [
        "binary_type_mapping = {'Normal': 0, 'Abnormal': 1}\n",
        "y = y.map(binary_type_mapping)"
      ]
    },
    {
      "cell_type": "code",
      "execution_count": 15,
      "id": "4c901afb-2d16-441c-a1ff-9d6b819fd871",
      "metadata": {
        "id": "4c901afb-2d16-441c-a1ff-9d6b819fd871"
      },
      "outputs": [],
      "source": [
        "X_train, X_test, y_train, y_test = train_test_split(X, y, test_size=0.2, stratify=y, random_state=42)"
      ]
    },
    {
      "cell_type": "code",
      "execution_count": 16,
      "id": "7720d067-e5c5-4fe4-87bf-fff0e1a0b7cd",
      "metadata": {
        "id": "7720d067-e5c5-4fe4-87bf-fff0e1a0b7cd"
      },
      "outputs": [],
      "source": [
        "scaler = MinMaxScaler()\n",
        "X_train = scaler.fit_transform(X_train)\n",
        "X_test = scaler.transform(X_test)"
      ]
    },
    {
      "cell_type": "code",
      "execution_count": 17,
      "id": "e421445f-b25d-4809-a611-df7416e02dc7",
      "metadata": {
        "id": "e421445f-b25d-4809-a611-df7416e02dc7"
      },
      "outputs": [],
      "source": [
        "smote = SMOTE(sampling_strategy='auto', random_state=42, k_neighbors=3)\n",
        "X_train_resampled, y_train_resampled = smote.fit_resample(X_train, y_train)"
      ]
    },
    {
      "cell_type": "code",
      "execution_count": 18,
      "id": "e6a193f5-35d3-48e3-b252-b898791ee3f8",
      "metadata": {
        "id": "e6a193f5-35d3-48e3-b252-b898791ee3f8"
      },
      "outputs": [],
      "source": [
        "# subset_size = 5000\n",
        "X_train_subsample = X_train_resampled\n",
        "y_train_subsample = y_train_resampled\n",
        "\n",
        "model = RandomForestClassifier(random_state=101, n_estimators=50)"
      ]
    },
    {
      "cell_type": "code",
      "execution_count": 19,
      "id": "61961ac4-e066-4021-a089-64b3f4bf0a19",
      "metadata": {
        "id": "61961ac4-e066-4021-a089-64b3f4bf0a19",
        "colab": {
          "base_uri": "https://localhost:8080/"
        },
        "outputId": "1d1ea04b-82f8-4386-9dc2-2b68c06f90a6"
      },
      "outputs": [
        {
          "output_type": "stream",
          "name": "stdout",
          "text": [
            "Cross-val scores:  [0.99769162 0.9979481  0.99794802 0.99790527 0.99786252]\n",
            "Avg cross-val score:  0.9978711043115485\n"
          ]
        }
      ],
      "source": [
        "cv = StratifiedKFold(n_splits=5, shuffle=True, random_state=42)\n",
        "scores = cross_val_score(model, X_train_subsample, y_train_subsample, cv=cv, scoring='accuracy')\n",
        "print(\"Cross-val scores: \", scores)\n",
        "print(\"Avg cross-val score: \", scores.mean())"
      ]
    },
    {
      "cell_type": "code",
      "execution_count": null,
      "id": "84b504ca-559c-449f-9fba-4de119878c23",
      "metadata": {
        "id": "84b504ca-559c-449f-9fba-4de119878c23"
      },
      "outputs": [],
      "source": [
        "param_grid = {\n",
        "    'n_estimators': [50, 100, 200],\n",
        "    'max_depth': [None, 10, 20],\n",
        "    'min_samples_split': [2, 5, 10],\n",
        "    'min_samples_leaf': [1, 2, 4]\n",
        "}\n",
        "\n",
        "grid_search = GridSearchCV(estimator=model, param_grid=param_grid, cv=cv, scoring='accuracy')\n",
        "grid_search.fit(X_train_subsample, y_train_subsample)\n",
        "\n",
        "print(\"Best params: \", grid_search.best_params_)\n",
        "print(\"Best cross-val score: \", grid_search.best_score_)"
      ]
    },
    {
      "cell_type": "code",
      "execution_count": null,
      "id": "ed28bb82-4b59-453e-aed6-af5669aec3b1",
      "metadata": {
        "scrolled": true,
        "id": "ed28bb82-4b59-453e-aed6-af5669aec3b1"
      },
      "outputs": [],
      "source": [
        "best_model = grid_search.best_estimator_\n",
        "best_model.fit(X_train_subsample, y_train_subsample)\n",
        "y_pred = best_model.predict(X_test)\n",
        "accuracy = accuracy_score(y_test, y_pred)\n",
        "print(f\"Accuracy: {accuracy}\")\n",
        "print(\"*** Confusion Matrix ***\")\n",
        "print(confusion_matrix(y_test, y_pred))\n",
        "print(\"*** Classification Report ***\")\n",
        "print(classification_report(y_test, y_pred, target_names=list(binary_type_names.values())))"
      ]
    },
    {
      "cell_type": "code",
      "execution_count": null,
      "id": "d0059c8d-4ffa-4bc9-89ee-5a2d2432458e",
      "metadata": {
        "id": "d0059c8d-4ffa-4bc9-89ee-5a2d2432458e"
      },
      "outputs": [],
      "source": [
        "train_sizes, train_scores, test_scores = learning_curve(best_model, X_train_subsample, y_train_subsample, cv=cv, scoring='accuracy', n_jobs=-1, train_sizes=np.linspace(0.1, 1.0, 10))"
      ]
    },
    {
      "cell_type": "code",
      "execution_count": null,
      "id": "f7c174ff-bc1e-47b9-9cfd-c43dda66c8eb",
      "metadata": {
        "id": "f7c174ff-bc1e-47b9-9cfd-c43dda66c8eb"
      },
      "outputs": [],
      "source": [
        "train_scores_mean = np.mean(train_scores, axis=1)\n",
        "train_scores_std = np.std(train_scores, axis=1)\n",
        "test_scores_mean = np.mean(test_scores, axis=1)\n",
        "test_scores_std = np.std(test_scores, axis=1)\n",
        "\n",
        "plt.figure(figsize=(10, 6))\n",
        "plt.title('Learning Curve')\n",
        "plt.xlabel('Training Examples')\n",
        "plt.ylabel('Accuracy Score')\n",
        "plt.grid()\n",
        "\n",
        "plt.fill_between(train_sizes, train_scores_mean - train_scores_std, train_scores_mean + train_scores_std, alpha=0.1, color=\"r\")\n",
        "plt.fill_between(train_sizes, test_scores_mean - test_scores_std, test_scores_mean + test_scores_std, alpha=0.1, color=\"g\")\n",
        "\n",
        "plt.plot(train_sizes, train_scores_mean, 'o-', color=\"r\", label=\"Training Score\")\n",
        "plt.plot(train_sizes, test_scores_mean, 'o-', color=\"g\", label=\"Cross-Validation Score\")\n",
        "\n",
        "plt.legend(loc=\"best\")\n",
        "plt.show()"
      ]
    },
    {
      "cell_type": "code",
      "execution_count": null,
      "id": "2ecc9656-ab84-4386-a179-54d8df1b62ee",
      "metadata": {
        "id": "2ecc9656-ab84-4386-a179-54d8df1b62ee"
      },
      "outputs": [],
      "source": []
    }
  ],
  "metadata": {
    "kernelspec": {
      "display_name": "Python 3",
      "name": "python3"
    },
    "language_info": {
      "codemirror_mode": {
        "name": "ipython",
        "version": 3
      },
      "file_extension": ".py",
      "mimetype": "text/x-python",
      "name": "python",
      "nbconvert_exporter": "python",
      "pygments_lexer": "ipython3",
      "version": "3.10.6"
    },
    "colab": {
      "provenance": [],
      "gpuType": "T4",
      "include_colab_link": true
    },
    "accelerator": "GPU"
  },
  "nbformat": 4,
  "nbformat_minor": 5
}